//
//  LSZFeedbackDetailsVC.m
//  JKFuYinProject
//
//  Created by 九酷 on 2018/8/15.
//  Copyright © 2018年 LC. All rights reserved.
//

#import "LSZFeedbackDetailsVC.h"

@interface LSZFeedbackDetailsVC ()<UITableViewDelegate,UITableViewDataSource>

@end

@implementation LSZFeedbackDetailsVC

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"我的反馈";
    self.view.backgroundColor = [UIColor whiteColor];
    UITableView * tableViewOpinion = [[UITableView alloc]initWithFrame:CGRectMake(0, 0, ScreenWidth, ScreenHeight) style:UITableViewStyleGrouped];
    tableViewOpinion.delegate = self;
    tableViewOpinion.dataSource = self;
    tableViewOpinion.separatorColor = divider;
    tableViewOpinion.separatorInset = UIEdgeInsetsMake(0, 20, 0, 20);
    tableViewOpinion.estimatedRowHeight =0;
    tableViewOpinion.estimatedSectionFooterHeight =0;
    tableViewOpinion.estimatedSectionHeaderHeight =0;
    [self.view addSubview:tableViewOpinion];
    [tableViewOpinion registerClass:[LSZHistoryTableViewCell class] forCellReuseIdentifier:@"LSZHistoryTableViewCell"];
 }
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView
{
    if (self.mg.reply.length > 0) {
        return 2;
    }else{
        return 1;
    }
}
- (NSInteger)tableView:(nonnull UITableView *)tableView numberOfRowsInSection:(NSInteger)section {
    return 1;
}
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath
{
    int a ;
    int b ;
    if (ScreenWidth == 320) {
        a = 13;
        b = 45;
    }else if(ScreenWidth == 375){
        a = 13.5;
        b = 50;
    }else {
        a = 14;
        b = 55;
    }
    CGFloat widthHeight;
    if (indexPath.section == 0) {
         widthHeight = [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-b height:ScreenHeight font:a :_mg.gnote];
    }else{
        widthHeight = [LSZSpecialPackaging caculateHeightOfText:ScreenWidth-b height:ScreenHeight font:a :_mg.reply];
    }
    if (ScreenWidth == 320) {
        return  40+widthHeight;
    }else if(ScreenWidth == 375){
        return 45+widthHeight;
    }else {
        return 50+widthHeight;
    }
}
-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    return 0.0001;
}
-(CGFloat)tableView:(UITableView *)tableView heightForFooterInSection:(NSInteger)section
{
    return 10;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    LSZHistoryTableViewCell * cell = [tableView dequeueReusableCellWithIdentifier:@"LSZHistoryTableViewCell" forIndexPath:indexPath];
    if (indexPath.section == 0) {
        [cell.imageViewHeader sd_setImageWithURL:[NSURL URLWithString:self.mg.avatar] placeholderImage:[UIImage imageNamed:@"placeholder"]];
        cell.labelName.text = self.mg.username;
        cell.labelTime.text = self.mg.add_time;
        cell.labelTitle.text = self.mg.gnote;
        CGFloat a;
        if (ScreenWidth == 320) {
            a = 13;
        }else if(ScreenWidth == 375){
            a = 13.5;
        }else {
            a = 14;
        }
        CGFloat widthHeight = [LSZSpecialPackaging caculateHeightOfText:cell.labelTitle.frame.size.width height:ScreenHeight font:a :cell.labelTitle.text];
        CGRect rect = cell.labelTitle.frame;
        rect.size.height = widthHeight;
        cell.labelTitle.frame = rect;
    }else{
        cell.imageViewHeader.image = [UIImage imageNamed:@"placeholder"];
        cell.labelName.text = @"客服回复";
        cell.labelTime.text = self.mg.reply_time;
        cell.labelTitle.text = self.mg.reply;
        CGFloat a;
        if (ScreenWidth == 320) {
            a = 13;
        }else if(ScreenWidth == 375){
            a = 13.5;
        }else {
            a = 14;
        }
        CGFloat widthHeight = [LSZSpecialPackaging caculateHeightOfText:cell.labelTitle.frame.size.width height:ScreenHeight font:a :cell.labelTitle.text];
        CGRect rect = cell.labelTitle.frame;
        rect.size.height = widthHeight;
        cell.labelTitle.frame = rect;
    }
    cell.selectionStyle = UITableViewCellSelectionStyleNone;
    return cell;
}
@end
